export default {
  setUser(state, options) {
    sessionStorage.setItem("token", options.token);
    const user = options.user;
    state.token = options.token;
    state.userState = {
      department: user.department,
      department_id: user.department_id,
      id: user.id,
      name: user.name,
      role: user.role,
      role_id: user.role_id,
      user_name: user.user_name,
      icon: user.icon
    };
    state.rightList = user.menu;
    state.permissions = user.permissions;
  },
  changeMessageList(state, obj) {
    console.log(state, obj)
    const index = state.messageList.findIndex(item => item.patient_id == obj.patient_id)
    if (index > -1) {
      const item = state.messageList.splice(index, 1)[0]
      obj.count = obj.count === '+1' ? Number(item.count) + 1 : obj.count
      state.messageList.unshift({ ...item, ...obj })
    } else {
      state.messageList.unshift(obj)
    }
  },

};
